
 /** \file bmp085.h
    \brief Header file for all #define constants and function prototypes
  
    
*/


#ifndef _BMP085_SENSOR_H
#define _BMP085_SENSOR_H

/******************************************************************************
                   Includes section
******************************************************************************/
#include <types.h>
#include <bspTaskManager.h>

//#include <debug.h>
//#include <stdio.h>

/******************************************************************************
                   Types section
******************************************************************************/
// states
typedef enum
{
  BMP085_IDLE,					// idle
  BMP085_GET_CAL,				// read calibration parameter
  BMP085_FORMAT_CAL_DATA,		// format the calibration parameters
  BMP085_SET_READ_TO_TEMP,		// set configuration register to temperature reading
  BMP085_GET_UTEMP,				// get uncalibrated calibrated temperature
  BMP085_SET_READ_TO_PRESSURE,	// set configuration register to pressure reading
  BMP085_GET_UPRESSURE,			// get calibrated pressure
  BMP085_WAIT,					// delay
  BMP085_DO_MATH  				// calculate real temperature and pressure
} Bmp085States_t;


// Control structure
typedef struct  {
	int16_t bmp085Temperature;								// temperature
	uint32_t bmp085Pressure;								// pressure
	bool bmp085Result;										// return value BC_SUCCESS/BC_FAIL
	void(* bmp085Callback)(bool error, uint32_t data);		// top layer task handler callback
} Bmp085Control_t;

/******************************************************************************
                   Prototypes section
******************************************************************************/

/**************************************************************************//**
\brief  Initializes the sensor and starts reads the calibration values.

\return
  BC_FAIL - if the sensor was open and running other tasks.
  BC_SUCCESS - other case.

******************************************************************************/
result_t initBmp085(void);

/**************************************************************************//**
\brief  Initializes the sensor and starts reads the calibration values.

\return
  BC_FAIL - if the sensor was open and running other tasks.
  BC_SUCCESS - other case.

******************************************************************************/
result_t openBmp085(void);

/**************************************************************************//**
\brief  Performs the test if the component have completed request.

\return
  BC_FAIL - the previous request is not completed.
  BC_SUCCESS - otherwise.
******************************************************************************/
result_t closeBmp085(void);

/**************************************************************************//**
\brief Reads the calibration values from memory.
******************************************************************************/
result_t calibrateBmp085(void);

/**************************************************************************//**
\brief Reads the temperature value.
******************************************************************************/
result_t readTemperatureBmp085(void);

/**************************************************************************//**
\brief Reads the pressure value.
******************************************************************************/
result_t readBmp085Data(int16_t temperature, void (*f)(bool result, uint32_t data));

#endif   // _BMP085_SENSOR_H_





